<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<title>ECharts</title>
	<!-- 引入 echarts.js -->
	<!-- <script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.min.js" type="text/javascript" charset="utf-8"></script> -->
	<style type="text/css">
		body{
			/*background-color: #00EEF6;*/
		}
		.acharts-main {
			width: 100%;
			min-width: 600px;
			height: 500px;
			float: left;
			/* border: 1px solid aqua; */
			box-sizing: border-box;
		}
	</style>
</head>
<body>

<p>
	公众号：<select style="height: 34px;" id="selectUserGzhList" ></select>
	起始时间：<input type="date" id="startDate" style="height: 34px;" placeholder="起始时间"/>
	截止时间：<input type="date" id="endDate" style="height: 34px;" placeholder="截止时间"/>
	<button id="query">查询</button>
	<button id="computeGzh">关注数计算</button>
</p>

<div class="acharts-main" id="main_05" ></div>

<div class="acharts-main" id="main_01" ></div>
<div class="acharts-main" id="main_02" ></div>
<#if shiro.hasPermission("sys:buserinfo:givevip")>
<div class="acharts-main" id="main_03"></div>
</#if>
<div class="acharts-main" id="main_04" ></div>

<!--<br/>-->
<!--<p>-->
<!--	<div class="acharts-main" id="main_06" ></div>-->
<!--	<div class="acharts-main" id="main_07" ></div>-->
<!--</p>-->
<!--<br/>-->
<!--<p>-->
<!--	<div class="acharts-main" id="main_08" ></div>-->
<!--	<div class="acharts-main" id="main_04" ></div>-->
<!--</p>-->

</body>
<script src="${request.contextPath}/statics/libs/jquery.min.js"></script>
<script src="${request.contextPath}/statics/aecharts/echarts.min.js" type="text/javascript" charset="utf-8"></script>
<script src="${request.contextPath}/statics/aecharts/chart_dateflow.data.js" type="text/javascript" charset="utf-8"></script>
<script>
$(function () {
	function CurentTime() {
		let now = new Date();

		let year = now.getFullYear(); //年
		let month = now.getMonth() + 1 + ''; //月
		let day = now.getDate() + ''; //日

		month = month.length == 1 ? '0' + month : month;
		day = day.length == 1 ? '0' + day : day;
		return year + '-' + month + '-' + day;
	}

	console.info(CurentTime());
	document.getElementById("startDate").value = CurentTime();
	document.getElementById("endDate").value = CurentTime();

	$.ajax({
		type: "POST",
		async:false,
		url: '../../sys/buserinfo/getUserGzhList',
		contentType: "application/json",
		success: function(r){
			if(r.code==0){
				for(var i=0;i<r.userGzhList.length;i++){
					$("#selectUserGzhList").append(
							"<option value=" + r.userGzhList[i].gzhCode +">"+ r.userGzhList[i].gzhName+"</option>");
				}
			}
		}
	});

	$("#computeGzh").click(function(){
		var gzhCode=$("#selectUserGzhList").val().trim();
		debugger;
		if(gzhCode==''){
			alert("请选择公众号");
			return false;
		}
		computeGzh(gzhCode);
	});

	$("#query").click(function(){
		var startDate=$("#startDate").val().trim();
		var endDate=$("#endDate").val().trim();
		var gzhCode=$("#selectUserGzhList").val().trim();
		debugger;
		if(gzhCode==''){
			alert("请选择公众号");
			return false;
		}
		loadData(startDate,endDate,gzhCode);
	});

	function loadData(startDate,endDate,gzhCode) {
		$.ajax({
			type: "POST",
			url: "../../sys/gzhrank/pushComparisonStatistics",
			contentType: "application/json",
			data: JSON.stringify({'startDate': startDate, 'endDate': endDate,'gzhCode':gzhCode}),
			success: function (r) {

				debugger;
				if (r.code == 0) {
					option_01.xAxis[0].data = r.pushDate;
					option_01.series[0].data = r.bar6;
					option_01.series[1].data = r.bar8;
					option_01.series[2].data = r.baryh;
					option_01.series[3].data = r.bar11;
					option_01.series[4].data = r.bar18;
					option_01.series[5].data = r.bar20;
					option_01.series[6].data = r.bar21;
					myChart_01.setOption(option_01);
				} else {

				}
			}
		});


		$.ajax({
			type: "POST",
			url: "../../sys/gzhrank/keywordsReplyStatistics",
			contentType: "application/json",
			data: JSON.stringify({'startDate': startDate, 'endDate': endDate,'gzhCode':gzhCode}),
			success: function (r) {

				debugger;
				if (r.code == 0) {
					option_02.xAxis[0].data = r.category;
					option_02.series[0].data = r.bar2;
					option_02.series[1].data = r.bar1;
					option_02.series[2].data = r.bar0;
					myChart_02.setOption(option_02);
				} else {

				}
			}
		});


		if(document.getElementById('main_03')) {
			$.ajax({
				type: "POST",
				url: "../../sys/gzhrank/orderPayStatistics",
				contentType: "application/json",
				data: JSON.stringify({'startDate': startDate, 'endDate': endDate, 'gzhCode': gzhCode}),
				success: function (r) {

					debugger;
					if (r.code == 0) {
						option_03.xAxis[0].data = r.category;
						option_03.series[0].data = r.bar0;
						option_03.series[1].data = r.bar1;
						option_03.series[2].data = r.bar2;
						option_03.series[3].data = r.bar3;
						myChart_03.setOption(option_03);
					} else {

					}
				}
			});
		}



		$.ajax({
			type: "POST",
			url: "../../sys/gzhrank/articleLookStatistics",
			contentType: "application/json",
			data: JSON.stringify({'startDate': startDate, 'endDate': endDate,'gzhCode':gzhCode}),
			success: function (r) {

				debugger;
				if (r.code == 0) {
					option_04.xAxis[0].data = r.lookDate;
					option_04.series[0].data = r.lookCount;
					option_04.series[1].data = r.shareCount;
					option_04.series[2].data = r.lookUserCount;
					option_04.series[3].data = r.shareUserCount;
					myChart_04.setOption(option_04);
				} else {

				}
			}
		});




		$.ajax({
			type: "POST",
			url: "../../sys/gzhrank/fansStatistics",
			contentType: "application/json",
			data: JSON.stringify({'startDate': startDate, 'endDate': endDate,'gzhCode':gzhCode}),
			success: function (r) {

				debugger;
				if (r.code == 0) {
					option_05.xAxis[0].data = r.getDate;
					option_05.series[0].data = r.newUserCount;
					option_05.series[1].data = r.cancelUserCount;
					option_05.series[2].data = r.growthUserCount;
					myChart_05.setOption(option_05);
				} else {

				}
			}
		});

	}

	function computeGzh(gzhCode) {
		$.ajax({
			type: "POST",
			url: "../../sys/gzhrank/getFans",
			contentType: "application/json",
			data: JSON.stringify({'gzhCode': gzhCode}),
			success: function (r) {

				alert("获取完成");
			}
		});
	}

});
</script>
</html>

